package com.candy.th2;

/**
 * @author donglin
 * @Title:
 * @类名: MyThread
 * @date 2020/7/22
 */
public class MyThread extends Thread{
    //终止变量
    private boolean stopped;

    public MyThread() {
    }

    public MyThread(String name) {
        super(name);
    }

    @Override
    public void run() {
        int i=0;
        for(;;){
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(this.getName()+".............."+i++);
            //判断线程是否终止
            if(stopped){
                break;
            }

        }
    }

    public boolean isStopped() {
        return stopped;
    }

    public void setStopped(boolean stopped) {
        this.stopped = stopped;
    }
}
